<!DOCTYPE html>
<html>
<head>
  <title>canvasCommand</title>
</head>
<body>
  <script type="text/javascript">
    var canvasCommand = (function() {
      var canvas = document.getElementById('canvas'),
      ctx = canvas.getcontext('2d');

      var Action = {
        fillstyle: function(c) {
          ctx.fillstyle = c;
        },

        fillRect(x,y, width, height) {
          ctx.fillRect(x,y,width, height);
        },

        strokestyle(c) {
          ctx.strokestyle = c;
        },

        strokeRect(x,y, width, height) {
          ctx.strokeRect(x,y,width, height);
        },

        fillText(text,x,y) {
          ctx.fillText(text,x,y)
        }
      }
    })();
  </script>
</body>
</html>